package com.ruoyi.common.controller;

import java.util.Date;
import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.entity.Mycreated;
import com.ruoyi.common.service.IMycreatedService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * VIEWController
 * 
 * @author dustball
 * @date 2021-04-23
 */
@RestController
@RequestMapping("/oa/mycreated")
public class MycreatedController extends BaseController
{
    @Autowired
    private IMycreatedService mycreatedService;

    /**
     * 查询VIEW列表
     */
    @PreAuthorize("@ss.hasPermi('oa:mycreated:list')")
    @GetMapping("/list")
    public TableDataInfo list(Mycreated mycreated)
    {
        startPage();
        List<Mycreated> list = mycreatedService.selectMycreatedList(mycreated);
        return getDataTable(list);
    }

    /**
     * 导出VIEW列表
     */
    @PreAuthorize("@ss.hasPermi('oa:mycreated:export')")
    @Log(title = "VIEW", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Mycreated mycreated)
    {
        List<Mycreated> list = mycreatedService.selectMycreatedList(mycreated);
        ExcelUtil<Mycreated> util = new ExcelUtil<Mycreated>(Mycreated.class);
        return util.exportExcel(list, "mycreated");
    }

    /**
     * 获取VIEW详细信息
     */
    @PreAuthorize("@ss.hasPermi('oa:mycreated:query')")
    @GetMapping(value = "/{starttime}")
    public AjaxResult getInfo(@PathVariable("starttime") Date starttime)
    {
        return AjaxResult.success(mycreatedService.selectMycreatedById(starttime));
    }

    /**
     * 新增VIEW
     */
    @PreAuthorize("@ss.hasPermi('oa:mycreated:add')")
    @Log(title = "VIEW", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Mycreated mycreated)
    {
        return toAjax(mycreatedService.insertMycreated(mycreated));
    }

    /**
     * 修改VIEW
     */
    @PreAuthorize("@ss.hasPermi('oa:mycreated:edit')")
    @Log(title = "VIEW", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Mycreated mycreated)
    {
        return toAjax(mycreatedService.updateMycreated(mycreated));
    }

    /**
     * 删除VIEW
     */
    @PreAuthorize("@ss.hasPermi('common:mycreated:remove')")
    @Log(title = "VIEW", businessType = BusinessType.DELETE)
	@DeleteMapping("/{starttimes}")
    public AjaxResult remove(@PathVariable Date[] starttimes)
    {
        return toAjax(mycreatedService.deleteMycreatedByIds(starttimes));
    }
}
